package com.newbingo.service;

import java.util.List;

import com.newbingo.dao.imple.IGameDao;
import com.newbingo.dao.imple.IGamePlayDao;
import com.newbingo.entity.BettingCell;
import com.newbingo.entity.GamePlay;
import com.newbingo.service.imple.IGamePlayService;
import com.newbingo.util.Pager;

public class GamePlayService implements IGamePlayService {
	private IGamePlayDao gamePlayDao;
	private IGameDao gameDao;

	/* 
	 * 添加一条游戏玩法,从gamePlay中获取游戏的编号，查询出设置到gamePlay中，并对gamePlay进行保存.
	 */
	public void createGamePlay(GamePlay gamePlay){
		gamePlay.setGame(gameDao.findById(gamePlay.getGame().getGameno()));
		gamePlayDao.save(gamePlay);
	}
	

	/* 
	 * 删除游戏玩法
	 */
	public void deleteGamePlay(GamePlay gamePlay){
		gamePlayDao.delete(gamePlay);
	}	
	
	/* 
	 *更新游戏玩法从gamePlay中获取游戏的编号，查询出设置到gamePlay中，并对gamePlay进行修改.
	 */
	public void updateGamePlay(GamePlay gamePlay){
		gamePlay.setGame(gameDao.findById(gamePlay.getGame().getGameno()));
		gamePlayDao.merge(gamePlay);
	}
	
	/**
	 * 根据游戏玩法ID查询
	 */
	public GamePlay findById(Integer id){
		return gamePlayDao.findById(id);
	}
	
	/**
	 * 根据游戏名称查询
	 */
	public List findByGameNo(Integer gameno){
		return gamePlayDao.findByGameNo(gameno);
	}
	
	/* 
	 * 分页查询
	 */
	public Pager findByPage(int start,int limit,Integer gameno){
		return gamePlayDao.findByPage(start, limit, gameno);
	}

	/* 
	 * 
	 */
	public IGamePlayDao getGamePlayDao() {
		return gamePlayDao;
	}

	/* 
	 * 
	 */
	public void setGamePlayDao(IGamePlayDao gamePlayDao) {
		this.gamePlayDao = gamePlayDao;
	}


	public IGameDao getGameDao() {
		return gameDao;
	}


	public void setGameDao(IGameDao gameDao) {
		this.gameDao = gameDao;
	}
	
}
